import { get } from 'lodash-es'

export class OpenUser {
  id?: string
  hotel_id?: string
  appid?: string
  mobile?: string
  /* 微信信息 */
  avatar?: string
  country?: string
  province?: string
  city?: string
  gender?: string
  language?: string
  nickname?: string
  session_key?: string
  openid?: string
  unionid?: string
  /* 微信信息 */
  created_at?: string
  updated_at?: string
  version?: number;
  [key: string]: any

  constructor(data?: OpenUser) {
    this.init(data)
  }
}

OpenUser.prototype.init = function init(data?: OpenUser) {
  this.id = get(data, 'id')
  this.hotel_id = get(data, 'hotel_id')
  this.appid = get(data, 'appid', '')
  this.mobile = get(data, 'mobile', '')
  this.avatar = get(data, 'avatar', '')
  this.country = get(data, 'country', '')
  this.province = get(data, 'province', '')
  this.city = get(data, 'city', '')
  this.gender = get(data, 'gender', '')
  this.language = get(data, 'language', '')
  this.nickname = get(data, 'nickname', '')
  this.session_key = get(data, 'session_key', '')
  this.openid = get(data, 'openid', '')
  this.unionid = get(data, 'unionid', '')
  this.created_at = get(data, 'created_at')
  this.updated_at = get(data, 'updated_id')
  this.version = get(data, 'version')
}
